﻿using System;
using System.Collections.Generic;
using System.Web;

namespace FDeal
{
    public class ThongTinTaiKhoanBUS
    {
        private ThongTinTaiKhoanDAO _dDAO;

        public ThongTinTaiKhoanBUS()
        {
            _dDAO = new ThongTinTaiKhoanDAO();
        }

        public void Insert(ThongTinTaiKhoanDTO obj)
        {
            _dDAO.insert(obj);
        }

        public void Insert(string idtaikhoan, string tendangnhap, string email, 
            string matkhau, string quocgia, string tinhthanh, string gioitinh,
            DateTime ngaysinh, string cauhoibimat, string traloichbm, int loaitaikhoan)
        {
            ThongTinTaiKhoanDTO obj = new ThongTinTaiKhoanDTO();

            obj.Idtaikhoan = idtaikhoan;
            obj.Tendangnhap = tendangnhap;
            obj.Email = email;
            obj.Matkhau = matkhau;
            obj.Quocgia = quocgia;
            obj.Tinhthanh = tinhthanh;
            obj.Gioitinh = gioitinh;
            obj.Ngaysinh = ngaysinh;
            obj.Cauhoibimat = cauhoibimat;
            obj.Traloichbm = traloichbm;
            obj.Loaitaikhoan = loaitaikhoan;

            this.Insert(obj);
        }
        public void Delete(string idDeal)
        {
            _dDAO.delete(idDeal);
        }

        public void Update(ThongTinTaiKhoanDTO obj)
        {
            _dDAO.update(obj);
        }

        public ThongTinTaiKhoanDTO[] GetDsThongTinTaiKhoan()
        {
            return _dDAO.getDsThongTinTaiKhoan();
        }

        public ThongTinTaiKhoanDTO GetThongTinTK(string idTaiKhoan)
        {
            ThongTinTaiKhoanDTO[] ds = this.GetDsThongTinTaiKhoan();

            for (int i = 0; i < ds.Length; i++)
            {
                if (ds[i].Idtaikhoan.Equals(idTaiKhoan))
                    return ds[i];
            }
            return null;
        }
    }
}